var text, selects;
var status = 0;
var 礼包总成 = [
    ["逆天装备自选[装备]", 4001889, 999, 30000, 5, [
        [2438817, 1]
    ]],
    ["高级称号套餐[装备]", 4001889, 999, 30000, 5, [
        [3700620, 1],
        [3700543, 1],
        [3700512, 1],
        [3700513, 1],
        [3700514, 1],
        [3700599, 1]
    ]],
    ["高级徽章套餐[装备]", 4001889, 999, 30000, 5, [
        [1182136, 1],
        [1182017, 1],
        [1142922, 1],
        [1142746, 1],
        [1142745, 1]
    ]],
    ["漆黑首领套[装备]", 4001889, 999, 28000, 5, [
        [1012632, 1],
        [1022278, 1],
        [1672082, 1],
        [1182285, 1],
        [1122430, 1],
        [1162083, 1],
        [1162082, 1],
        [1162081, 1],
        [1162080, 1],
        [1132308, 1],
        [1113306, 1],
        [1113302, 1],
        [1032316, 1]
    ]],
    ["神秘套装[装备]", 4001889, 999, 28000, 5, [
        [2430029, 1],
        [2433442, 6]
    ]],
    ["埃苏套装[装备]", 4001878, 999, 23000, 3, [
        [2434340, 1],
        [2437534, 6]
    ]],
    ["漩涡套装[装备]", 4001878, 999, 23000, 3, [
        [2436471, 1],
        [1152160, 1],
        [1122269, 1],
        [1102623, 1],
        [1082556, 1],
        [1072870, 1],
        [1052669, 1],
        [1032224, 1],
        [1022211, 1],
        [1012438, 1],
        [1003976, 1],
        [1132247, 1],
        [2610002, 99],
        [2612015, 25],
        [2613007, 25],
        [2616206, 50],
        [2615004, 30],
        [2048909, 10]
    ]],
    ["起源戒指套餐[装备]", 4001878, 99, 23000, 2, [
        [1113098, 1],
        [1113099, 1],
        [1113100, 1],
        [1113101, 1],
        [1113102, 1],
        [1113103, 1],
        [1113105, 1],
        [1113106, 1],
        [1113107, 1],
        [1113108, 1],
        [1113117, 1],
        [1113118, 1],
        [1113119, 1],
        [1113120, 1],
        [1113122, 1],
        [1113126, 1],
        [1113127, 1],
        [1113128, 1]
    ]],
    ["最高贝勒德套[装备]", 4310097, 999, 15000, 3, [
        [1132246, 1],
        [1122267, 1],
        [1113075, 1],
        [1032223, 1],
        [2615001, 99]
    ]],
    ["高贝勒德套[装备]", 4310097, 666, 13000, 2, [
        [1132245, 1],
        [1122266, 1],
        [1113074, 1],
        [1032222, 1],
        [2615001, 99]
    ]],
    ["法弗纳套装[装备]", 4001868, 999, 5000, 1, [
        [2431938, 1],
        [2432341, 3]
    ]],
    ["战国套装[装备]", 4001868, 700, 5000, 1, [
        [2430217, 1],
        [2430216, 7]
    ]],
    ["女皇套装[装备]", 4000658, 999, 2000, 1, [
        [2431944, 1],
        [2431945, 6]
    ]],
    ["巨匠套装[装备]", 4000000, 999, 700, 1, [
        [2431937, 1],
        [1032200, 1],
        [1152154, 1],
        [1113055, 1]
    ]],
    ["凯梅尔兹套装[装备]", 4000054, 999, 400, 1, [
        [2433295, 1],
        [1142981, 1],
        [1132248, 1],
        [1122272, 1],
        [1102626, 1],
        [1082559, 1],
        [1072874, 1],
        [1052673, 1],
        [1032225, 1],
        [1022212, 1],
        [1012439, 1],
        [1003984, 1]
    ]],
    ["橡果侦探团[装备]", 4000273, 999, 400, 1, [
        [1113254, 1],
        [1113255, 1],
        [1113256, 1],
        [1113257, 1],
        [2049224, 20]
    ]],
    ["金花套[装备]", 4009362, 999, 380, 1, [
        [1012545, 1],
        [1022255, 1],
        [1032258, 1],
        [1113210, 1],
        [1122322, 1],
        [1132294, 1],
        [1152192, 1],
        [1162037, 1],
        [1182175, 1],
        [2615036, 30],
        [2615035, 30]
    ]],
    ["BOSS饰品套[装备]", 4310224, 999, 500, 1, [
        [1012478, 1],
        [1022231, 1],
        [1022232, 1],
        [1022277, 1],
        [1032136, 1],
        [1032241, 1],
        [1113149, 1],
        [1113282, 1],
        [1132296, 1],
        [1122000, 1],
        [1122076, 1],
        [1122254, 1],
        [1122150, 1],
        [1132272, 1],
        [1152170, 1],
        [1162025, 1],
        [1162009, 1],
        [1182087, 1]
    ]],
    ["至尊血腥套装", 4000082, 999, 666, 1, [
        [1702786, 1],
        [1005037, 1],
        [1005038, 1],
        [1050472, 1],
        [1051539, 1],
        [1070091, 1],
        [1071108, 1],
        [1103053, 1]
    ]],
    ["阴影之主套装", 4000082, 999, 666, 1, [
        [1702919, 1],
        [1005356, 1],
        [1050520, 1],
        [1051589, 1],
        [1070111, 1],
        [1071127, 1],
        [1103187, 1]
    ]],
    ["死亡之刃套装", 4000082, 999, 666, 1, [
        [1004450, 1],
        [1050356, 1],
        [1051426, 1],
        [1073041, 1],
        [1102809, 1],
        [1702565, 1]
    ]],
    ["死灵术士套装", 4000082, 999, 666, 1, [
        [1005260, 1],
        [1005261, 1],
        [1050505, 1],
        [1051575, 1],
        [1070105, 1],
        [1071121, 1],
        [1103148, 1],
        [1071121, 1],
        [1702876, 1]
    ]],
    ["甜甜雪花套装", 4000082, 999, 666, 1, [
        [1005272, 1],
        [1050507, 1],
        [1051577, 1],
        [1073322, 1],
        [1103152, 1],
        [1702882, 1]
    ]],
    ["咯咯嗒小鸡套装", 4000082, 999, 666, 1, [
        [1003965, 1],
        [1052661, 1],
        [1082549, 1],
        [1702461, 1]
    ]],
    ["海豹白白套装", 4000082, 999, 666, 1, [
        [1003713, 1],
        [1052550, 1],
        [1082493, 1],
        [1702454, 1]
    ]],
    ["山茶花套装", 4000082, 999, 666, 1, [
        [1005280, 1],
        [1005281, 1],
        [1082448, 1],
        [1051579, 1],
        [1070107, 1],
        [1071123, 1],
        [1103157, 1],
        [1702887, 1]
    ]],
    ["薰衣草旋律套装", 4000082, 999, 666, 1, [
        [1005319, 1],
        [1050514, 1],
        [1051584, 1],
        [1073335, 1],
        [1103171, 1],
        [1702901, 1]
    ]],
    ["血腥套装", 4000082, 999, 666, 1, [
        [1003934, 1],
        [1052644, 1],
        [1052643, 1],
        [1102605, 1],
        [1702444, 1],
        [1072848, 1]
    ]],
    ["大师斯泰拉套装", 4000082, 999, 666, 1, [
        [1005209, 1],
        [1005210, 1],
        [1050497, 1],
        [1051565, 1],
        [1070100, 1],
        [1071117, 1],
        [1103126, 1],
        [1103127, 1],
        [1702856, 1]
    ]],
    ["小小画家套装", 4000082, 999, 666, 1, [
        [1005143, 1],
        [1050486, 1],
        [1051553, 1],
        [1073271, 1],
        [1103094, 1],
        [1702826, 1]
    ]],
    ["珊瑚海套装", 4000082, 999, 666, 1, [
        [1005217, 1],
        [1005218, 1],
        [1050499, 1],
        [1051567, 1],
        [1073302, 1],
        [1103130, 1],
        [1702858, 1]
    ]],
    ["夏日海洋套装", 4000082, 999, 666, 1, [
        [1003636, 1],
        [1702375, 1],
        [1052536, 1],
        [1102491, 1],
        [1072893, 1]
    ]],
    ["火焰侦探套装", 4000082, 999, 666, 1, [
        [1005231, 1],
        [1005232, 1],
        [1053351, 1],
        [1053352, 1],
        [1073308, 1],
        [1103138, 1],
        [1702865, 1]
    ]],
    ["凶暴兔套装", 4000082, 999, 666, 1, [
        [1005327, 1],
        [1053416, 1],
        [1073342, 1],
        [1103177, 1],
        [1702907, 1]
    ]],
    ["星之记录者套装", 4000082, 999, 666, 1, [
        [1005368, 1],
        [1005369, 1],
        [1050523, 1],
        [1051593, 1],
        [1070113, 1],
        [1071129, 1],
        [1082744, 1],
        [1702928, 1]
    ]],
    ["消亡旅途套装", 4000082, 999, 666, 1, [
        [1005364, 1],
        [1053440, 1],
        [1103193, 1],
        [1073356, 1],
        [1702925, 1]
    ]],
    ["永爱大海套装", 4000082, 999, 666, 1, [
        [1005386, 1],
        [1050525, 1],
        [1051595, 1],
        [1070114, 1],
        [1071130, 1],
        [1103202, 1],
        [1702937, 1]
    ]],
    ["蓝天花蝴蝶套装", 4000082, 999, 666, 1, [
        [1005399, 1],
        [1050530, 1],
        [1051601, 1],
        [1073378, 1],
        [1103212, 1],
        [1702945, 1]
    ]],
    ["小熊夜晚散步套装", 4000082, 999, 666, 1, [
        [1005412, 1],
        [1050531, 1],
        [1051602, 1],
        [1073362, 1],
        [1103219, 1],
        [1702951, 1]
    ]],
    ["午夜月光套装", 4000082, 999, 666, 1, [
        [1005419, 1],
        [1005420, 1],
        [1050534, 1],
        [1051605, 1],
        [1073390, 1],
        [1103221, 1],
        [1702956, 1]
    ]],
    ["女仆执事套装", 4000082, 999, 666, 1, [
        [1003971, 1],
        [1003972, 1],
        [1050302, 1],
        [1051369, 1],
        [1072868, 1],
        [1102621, 1],
        [1702464, 1]
    ]],
    ["岩炎赎罪套装", 4000082, 999, 666, 1, [
        [1004002, 1],
        [1050305, 1],
        [1051373, 1],
        [1070057, 1],
        [1071074, 1],
        [1102632, 1],
        [1702473, 1]
    ]],
    ["邦尼大师套装", 4000082, 999, 666, 1, [
        [1000070, 1],
        [1001093, 1],
        [1050312, 1],
        [1051384, 1],
        [1072908, 1],
        [1702488, 1],
        [1082580, 1]
    ]],
    ["泡泡秋游套装", 4000082, 999, 666, 1, [
        [1000074, 1],
        [1001097, 1],
        [1050319, 1],
        [1051390, 1],
        [1070059, 1],
        [1071076, 1],
        [1102674, 1],
        [1702503, 1]
    ]],
    ["派对日记套装", 4000082, 999, 666, 1, [
        [1004158, 1],
        [1050322, 1],
        [1051392, 1],
        [1702512, 1],
        [1102688, 1],
        [1070061, 1],
        [1071078, 1]
    ]],
    ["清晨散步套装", 4000082, 999, 666, 1, [
        [1005193, 1],
        [1050495, 1],
        [1051563, 1],
        [1073298, 1],
        [1103118, 1],
        [1702850, 1]
    ]],
    ["无敌啦啦队长套装", 4000082, 999, 666, 1, [
        [1004327, 1],
        [1050346, 1],
        [1051415, 1],
        [1073011, 1],
        [1102758, 1],
        [1702549, 1]
    ]],
    ["漆黑之翼套装", 4000082, 999, 666, 1, [
        [1005227, 1],
        [1050501, 1],
        [1051571, 1],
        [1070102, 1],
        [1071119, 1],
        [1012666, 1],
        [1702864, 1]
    ]],
    ["蝴蝶套装", 4000082, 999, 666, 1, [
        [1102453, 1],
        [1003581, 1],
        [1042241, 1],
        [1062156, 1],
        [1702367, 1]
    ]],
    ["胖胖企鹅套装", 4000082, 999, 666, 1, [
        [1053509, 1],
        [1073398, 1],
        [1005445, 1]
    ]]
];
var giftId = -1;
var 礼包内容 = null;
var 币种需求 = 999;
var 使用货币 = 0;
var 币种价格 = 1000;
var 缺少币种 = 0;
var 点券尾款 = 0;
var 仅有币种数量 = 0;
var 喇叭数量 = 0;

function start() {
    status = -1;
    action(1, 0, 0)
}

function action(p, c, y) {
    var b = cm.getConstantScriptContent("菜单_NPC立绘");
    var e = Math.floor(Math.random() * b.length);
    var v = b[e][0];
    var g = randomNum(0, b[e][1]);
    if (status == 0 && p == 0) {
        cm.dispose();
        cm.openNpc(0, "新购物中心_至尊版");
        return
    }
    if (p <= 0 && status > 0) {
        cm.dispose();
        cm.openNpc(0, "新购物中心_至尊版");
        return
    }
    if (p == 1) {
        status++
    } else {
        status--
    }
    if (cm.getzhizunvip() != 2) {
        cm.dispose();
        cm.playerMessage(1, "该菜单是至尊版专享。");
        return
    }
    if (status == 0) {
        var m = "#face" + g + "##fn方正粗黑宋简体##fs17#";
        m += "     #fs17##r欢迎使用 " + cm.getServerName() + " 购买礼包#k#fs14#\r\n";
        m += "      点击可以#r查看礼包#k内容哦！ 货币不足时#r使用点券#k购买：\r\n#fn黑体##fs14##b";
        for (var s = 0; s < 礼包总成.length; s++) {
            m += " #L" + (s) + "#" + 礼包总成[s][0] + "";
            var h = 10;
            var k = 礼包总成[s][0].length;
            var r = k;
            for (var t = 0; t < k; t++) {
                if (礼包总成[s][0].charCodeAt(t) < 0 || 礼包总成[s][0].charCodeAt(t) > 255) {
                    r++
                }
            }
            var u = h - (r / 2);
            for (var q = 0; q < u; q++) {
                m += "　"
            }
            m += "#l";
            if (s != 0 && (s + 1) % 3 == 0) {
                m += "\r\n"
            }
        }
        cm.askMenu_Bottom(m, 204, v)
    } else {
        if (status == 1) {
            giftId = parseInt(y);
            使用币种 = 礼包总成[giftId][1];
            币种需求 = 礼包总成[giftId][2];
            币种价格 = 礼包总成[giftId][3];
            喇叭数量 = 礼包总成[giftId][4];
            礼包内容 = 礼包总成[giftId][5];
            var m = "#face" + g + "##fn方正粗黑宋简体##fs17#";
            m += "  #r" + 礼包总成[giftId][0] + "#k 内容：#b\r\n\r\n#fn黑体##fs14#";
            for (var s = 0; s < 礼包内容.length; s++) {
                var l = 礼包内容[s][0];
                var f = 礼包内容[s][1];
                m += " #b#v" + l + "##z" + l + "##k #rx" + f + "#k";
                var h = 16;
                var k = 礼包总成[s][0].length;
                var r = k;
                for (var t = 0; t < k; t++) {
                    if (礼包总成[s][0].charCodeAt(t) < 0 || 礼包总成[s][0].charCodeAt(t) > 255) {
                        r++
                    }
                }
                var u = h - r;
                for (var q = 0; q < u; q++) {
                    m += " "
                }
                m += "#l";
                if (s != 0 && (s + 1) % 3 == 0) {
                    m += "\r\n"
                }
            }
            m += "\r\n  #fn方正粗黑宋简体##fs17#是否花费 #r" + 币种需求 + "#v" + 使用币种 + "##k 购买礼包？#fs15##r（币种不足时使用点券支付尾款）#k#fs17#";
            cm.askAcceptDecline_Bottom(m, 204, v);
            selects = y
        } else {
            if (status == 2) {
                ii = cm.getItemInfo();
                if (giftId != -1 && 礼包内容 != null) {
                    if (cm.getSpace(1) < 10 || cm.getSpace(2) < 10 || cm.getSpace(3) < 10 || cm.getSpace(4) < 10 || cm.getSpace(5) < 10) {
                        cm.getTopMsgFont("您的背包空间不足10格", 3, 20, 4, 0, 0);
                        cm.effect_NormalSpeechBalloon("您的背包空间不足10格", 1, 0, 0, 4000, 0, 0);
                        cm.dispose();
                        return
                    }
                    if (cm.haveItem(使用币种, 币种需求)) {
                        for (var w in 礼包内容) {
                            var l = 礼包内容[w][0];
                            var f = 礼包内容[w][1];
                            cm.gainItem(l, f)
                        }
                        cm.gainItem(使用币种, -币种需求);
                        cm.getTopMsgFont("购买礼包：" + 礼包总成[selects][0] + "", 3, 20, 20, 0);
                        cm.effect_NormalSpeechBalloon("购买成功：" + 礼包总成[selects][0] + "", 1, 0, 0, 4000, 0, 0);
                        cm.dispose();
                        for (var j = 0; j < 喇叭数量; j++) {
                            cm.worldSpouseMessage(23, "[礼包购买]  : 卧槽6666666！！岛民“" + cm.getPlayer().getName() + "”入手大礼包 " + 礼包总成[giftId][0] + " ！！！")
                        }
                        cm.worldSpouseMessage(25, "[礼包购买-" + cm.getPlayer().getName() + "] : 我本次使用了 " + ii.getName(使用币种) + " -" + 币种价格 + "个 / 点券 -" + 点券尾款 + "");
                        cm.playerMessage(6, "[礼包购买]：" + ii.getName(使用币种) + " -" + 币种价格 + "个")
                    } else {
                        ii = cm.getItemInfo();
                        仅有币种数量 = cm.getItemQuantity(使用币种);
                        缺少币种 = 币种需求 - cm.getItemQuantity(使用币种);
                        点券尾款 = 缺少币种 * 币种价格;
                        var a = "#face" + g + "##fn方正粗黑宋简体##fs16#";
                        a += "  #r" + 礼包总成[giftId][0] + "#k\r\n\r\n#fs15#";
                        a += "   #v" + 使用币种 + "#（" + 仅有币种数量 + "/" + 币种需求 + "）还差" + 缺少币种 + "个货币才可以购买\r\n";
                        a += "   #b#v" + 使用币种 + "##z" + 使用币种 + "##k 估价" + 币种价格 + "点券 / 每个\r\n\r\n";
                        a += "  #fs17##r是否 使用仅有的 #v" + 使用币种 + "#" + cm.getItemQuantity(使用币种) + "个 #e+#n " + 点券尾款 + " 点券 继续购买？#k";
                        cm.askAcceptDecline_Bottom(a, 204, v)
                    }
                } else {
                    cm.getTopMsgFont("购买错误！请联系管理员！", 3, 20, 20, 0);
                    cm.dispose()
                }
            } else {
                if (status == 3) {
                    if (cm.getPlayer().getCSPoints(1) < 点券尾款) {
                        cm.getTopMsgFont("点券不足啊！~", 3, 20, 20, 0);
                        cm.dispose();
                        return
                    } else {
                        if (giftId != -1 && 礼包内容 != null) {
                            for (var w in 礼包内容) {
                                var l = 礼包内容[w][0];
                                var f = 礼包内容[w][1];
                                cm.gainItem(l, f)
                            }
                            cm.gainItem(使用币种, -仅有币种数量);
                            cm.getPlayer().modifyCSPoints(1, -点券尾款, true);
                            cm.getTopMsgFont("购买礼包：" + 礼包总成[selects][0] + "", 3, 20, 20, 0);
                            cm.effect_NormalSpeechBalloon("购买成功：" + 礼包总成[selects][0] + "", 1, 0, 0, 4000, 0, 0);
                            cm.dispose();
                            for (var j = 0; j < 喇叭数量; j++) {
                                cm.worldSpouseMessage(23, "[礼包购买]  : 卧槽6666666！！岛民“" + cm.getPlayer().getName() + "”入手大礼包 " + 礼包总成[giftId][0] + " ！！！")
                            }
                            cm.worldSpouseMessage(25, "[礼包购买-" + cm.getPlayer().getName() + "] : 我本次使用了 " + ii.getName(使用币种) + " -" + 仅有币种数量 + "个 / 点券 -" + 点券尾款 + "");
                            ii = cm.getItemInfo();
                            cm.playerMessage(6, "[礼包购买]：" + ii.getName(使用币种) + " -" + 仅有币种数量 + "个");
                            cm.playerMessage(6, "[礼包购买]：点券 -" + 点券尾款 + "")
                        } else {
                            cm.getTopMsgFont("购买错误！请联系管理员！", 3, 20, 20, 0);
                            cm.dispose()
                        }
                    }
                }
            }
        }
    }
}
var cal = java.util.Calendar.getInstance();
var year = cal.get(java.util.Calendar.YEAR);
var month = cal.get(java.util.Calendar.MONTH) + 1;
var day = cal.get(java.util.Calendar.DATE);
var hour = cal.get(java.util.Calendar.HOUR_OF_DAY);
var min = cal.get(java.util.Calendar.MINUTE);
var sec = cal.get(java.util.Calendar.SECOND);
var weekday = cal.get(java.util.Calendar.DAY_OF_WEEK) - 1;
var weekName = ["日", "一", "二", "三", "四", "五", "六"];

function 字符填充(c, g) {
    var b = c;
    var i = g.length;
    var h = i;
    for (var f = 0; f < i; f++) {
        if (g.charCodeAt(f) < 0 || g.charCodeAt(f) > 255) {
            h++
        }
    }
    var a = b - (h / 2);
    if (h > 0) {
        for (var e = 0; e < a; e++) {
            text += "　"
        }
    } else {
        text += "　"
    }
}

function randomNum(b, a) {
    switch (arguments.length) {
        case 1:
            return parseInt(Math.random() * b + 1, 10);
            break;
        case 2:
            return parseInt(Math.random() * (a - b + 1) + b, 10);
            break;
        default:
            return 0;
            break
    }
};